// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Solid Block Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 48 : TYPE_SOLIDBLOCK

// Function declarations
reserve function SolidBlock_DebugDraw
reserve function SolidBlock_DebugSpawn

// Static Values

// Tables

function SolidBlock_DebugDraw
	DrawSprite(0)
end function


function SolidBlock_DebugSpawn
	CreateTempObject(TypeName[Solid Block], 0, object.xpos, object.ypos)
end function


event ObjectMain
	foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
		if object[currentPlayer].state == PlayerObject_HandleMonikaTeleport
			if object[0].value1 > 20
				BoxCollisionTest(C_BOX, object.entityPos, -16, -16, 16, 16, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
			else
				if object[0].value1 >= 17
					BoxCollisionTest(C_TOUCH, object.entityPos, -16, -16, 16, 16, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
					if checkResult == 1
						if object[currentPlayer].xpos > object.xpos
							object[currentPlayer].ixpos = object[currentPlayer].collisionLeft
							FlipSign(object[currentPlayer].xpos)
							object[currentPlayer].xpos += 0x100000
							object[currentPlayer].xpos += object.xpos
							if object[currentPlayer].xvel < 0
								object[currentPlayer].pushing = 2
								object[currentPlayer].xvel = 0
								object[currentPlayer].speed = 0
							end if
						else
							object[currentPlayer].ixpos = object[currentPlayer].collisionRight
							FlipSign(object[currentPlayer].xpos)
							object[currentPlayer].xpos -= 0x100000
							object[currentPlayer].xpos += object.xpos
							if object[currentPlayer].xvel > 0
								object[currentPlayer].pushing = 2
								object[currentPlayer].xvel = 0
								object[currentPlayer].speed = 0
							end if
						end if
					end if
				end if
			end if
		else	
			BoxCollisionTest(C_BOX, object.entityPos, -16, -16, 16, 16, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
		end if		
	next
end event


event ObjectDraw
	DrawSprite(0)
end event


event ObjectStartup
	LoadSpriteSheet("SYZ/Objects.gif")
	SpriteFrame(-16, -16, 32, 32, 119, 34)
	SetTableValue(TypeName[Solid Block], DebugMode_ObjCount, DebugMode_TypesTable)
	SetTableValue(SolidBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
	SetTableValue(SolidBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
	DebugMode_ObjCount++
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
